// pages/paymentSuccess/paymentSuccess.js
Page({
  data: {
    orderNumber: '',
    paymentTime: '',
    amount: '0.00'
  },

  onLoad(options) {
    // 从URL参数获取订单号
    if (options.orderNo) {
      this.setData({
        orderNumber: options.orderNo,
        paymentTime: new Date().toLocaleString(),
        amount: '0.00' // 这里可以从订单信息中获取实际金额
      });

      // 从本地存储获取订单信息
      const orderList = wx.getStorageSync('orderList') || [];
      const currentOrder = orderList.find(order => order.orderNo === options.orderNo);
      
      if (currentOrder) {
        this.setData({
          amount: currentOrder.totalPrice
        });
      }
    }
  },

  // 查看订单
  viewOrder() {
    wx.navigateTo({
      url: '/pages/order/order'
    });
  },

  // 返回首页
  goHome() {
    wx.switchTab({
      url: '/pages/index/index'
    });
  }
});